package com.akk.action;

import com.akk.module.avs.entity.AvsPartner;
import com.akk.module.avs.service.AvsPartnerService;
import com.akk.utils.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * 合作商在爱卡卡平台信息
 *
 * @company www.lovekaka.com
 * @auther hainlc
 * @create 2017/05/11 9:31
 */
@Controller
@RequestMapping("/thmlfApi")
public class ThmPartnerAction {

    @Autowired
    private AvsPartnerService partnerService;

    /**
     * 根据合作商的姓名和类型查询
     */
    @RequestMapping(value = "/queryInfo", method = RequestMethod.POST)
    @ResponseBody
    public RestResponse queryInfo(@RequestBody AvsPartner partnerEntity) {
        if (!StringUtils.isEmpty(partnerEntity.getIdCard())) {
            partnerEntity.setIdCard(partnerEntity.getIdCard().toUpperCase());
        }
        List<AvsPartner> partnerEntityDB = partnerService.queryList(partnerEntity);
        if (partnerEntityDB == null || partnerEntityDB.size() == 0)
            return RestResponse.build("1", "信息不存在");
        if (partnerEntityDB.isEmpty())
            return RestResponse.build("1", "信息不存在");
        return RestResponse.build(partnerEntityDB.get(0));
    }
}
